﻿<UserControl x:Class="SD.Shapes.Samples.Connectors.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sd="http://schemas.silverdiagram.net/sd/2010/xaml"
    xmlns:shapesBasic="clr-namespace:SD.Shapes.Templates.Basic;assembly=SD.Shapes.Templates.Basic"
    xmlns:local="clr-namespace:SD.Shapes.Samples.Connectors"
    mc:Ignorable="d"
    d:DesignHeight="600" d:DesignWidth="800">
    
    <UserControl.Resources>
        <Style x:Key="ExampleShape" TargetType="shapesBasic:Rectangle">
            <Setter Property="Width" Value="150" />
            <Setter Property="Height" Value="80" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Grid>
                            <Rectangle Fill="LightGoldenrodYellow"
                                Stroke="Black"
                                StrokeThickness="1" />

                            <Grid Margin="5">
                                <TextBlock Text="Output (Warned)"
                                    HorizontalAlignment="Center" VerticalAlignment="Top" />
                                <TextBlock Text="Input (Warned)"
                                    HorizontalAlignment="Center" VerticalAlignment="Bottom" />
                                <TextBlock Text="Output"
                                    HorizontalAlignment="Left" VerticalAlignment="Center" />
                                <TextBlock Text="Input"
                                    HorizontalAlignment="Right" VerticalAlignment="Center" />
                            </Grid>

                            <local:ConnectorWarningOut Margin="0,-4,0,0"
                                HorizontalAlignment="Center" VerticalAlignment="Top" />
                            <local:ConnectorWarningIn Margin="0,0,0,-4"
                                HorizontalAlignment="Center" VerticalAlignment="Bottom" />
                            <sd:Connector Direction="Output" Margin="-4,0,0,0"
                                HorizontalAlignment="Left" VerticalAlignment="Center" />
                            <sd:Connector Direction="Input" Margin="0,0,-4,0"
                                HorizontalAlignment="Right" VerticalAlignment="Center" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    
    <Grid Background="White">
        <ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible" Background="#EEE">
            <Grid Width="700" Height="500" Background="White" Margin="20">
                <sd:GridRenderer Margin="10" />

                <sd:Diagram Background="Transparent">
                    <shapesBasic:BasicConnection SinkDecorator="Arrow">
                        <shapesBasic:BasicConnection.PathCalculator>
                            <sd:OrthogonalPathCalculator />
                        </shapesBasic:BasicConnection.PathCalculator>
                        <shapesBasic:BasicConnection.Source>
                            <sd:ConnectionPoint ConnectedNode="{Binding ElementName=Rectangle1}" ConnectorIndex="2" />
                        </shapesBasic:BasicConnection.Source>
                        <shapesBasic:BasicConnection.Sink>
                            <sd:ConnectionPoint ConnectedNode="{Binding ElementName=Rectangle2}" ConnectorIndex="3" />
                        </shapesBasic:BasicConnection.Sink>
                    </shapesBasic:BasicConnection>
                    
                    <shapesBasic:Rectangle x:Name="Rectangle2" Style="{StaticResource ExampleShape}" Position="450,200" />
                    <shapesBasic:Rectangle x:Name="Rectangle1" Style="{StaticResource ExampleShape}" Position="100,50" />
                </sd:Diagram>
            </Grid>
        </ScrollViewer>
    </Grid>
</UserControl>
